//
//  QSViewController.m
//  QSWKComponent
//
//  Created by git-hushuai on 08/20/2020.
//  Copyright (c) 2020 git-hushuai. All rights reserved.
//

#import "QSViewController.h"
#import <SLWkWebViewIndex.h>
#import <YYWebImage/YYWebImage.h>

@interface QSViewController ()


@property (nonatomic ,strong) YYAnimatedImageView *topImageView;

@property (nonatomic ,strong) UIImageView *bottomImageView;

@end


#define kScreenW  [UIScreen mainScreen].bounds.size.width

@implementation QSViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    

    
}


- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    
    [self.view addSubview:self.topImageView];
    //    self.topImageView.backgroundColor = [UIColor systemPinkColor];
        
        [self.view addSubview:self.bottomImageView];
    //    self.bottomImageView.backgroundColor = [UIColor redColor];
        
        
    [self.topImageView yy_setImageWithURL:[NSURL URLWithString:@"https://imgcdn.chuxingyouhui.com/pintuan/mng/20200825/78998f3d86864f8f97fa5ee8c2cb173a.jpeg"] placeholder:nil options:YYWebImageOptionIgnoreFailedURL completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
        
//          UIImage *image = [UIImage imageNamed:@"topNav"];
            image =  [image yy_imageByResizeToSize:CGSizeMake(kScreenW, XBScale(44)+64) contentMode:UIViewContentModeScaleToFill];
        
            self.topImageView.image = image;
    }];
        
    //    NSLog(@"image info :%@==%@",image,@(kScreenW));
    //    self.topImageView.image = image;
    [self.bottomImageView yy_setImageWithURL:[NSURL URLWithString:@"https://imgcdn.chuxingyouhui.com/pintuan/mng/20200825/2851218acef14141ad204a0547eee8ca.jpeg"] options:YYWebImageOptionProgressiveBlur];
}


- (YYAnimatedImageView *)topImageView
{
    if (!_topImageView) {
        
        _topImageView = [YYAnimatedImageView new];
        
        _topImageView.frame = CGRectMake(0, 0, kScreenW , 88 + ceilf(XBScale(44)));
    }
    return _topImageView;
}


- (UIImageView *)bottomImageView
{
    if (!_bottomImageView) {
        
        _bottomImageView = [UIImageView new];
        
        _bottomImageView.frame = CGRectMake(0, CGRectGetMaxY(self.topImageView.frame)-0.5, kScreenW, XBScale(145));
    }
    return _bottomImageView;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
